home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 1997 #1 / Amiga Plus CD - 1997 - No. 01.iso / pd / programmierung / proasm / examples / pro68 / pro68.s < prev   
Text File  |  1996-04-25  |  6KB  |  265 lines

  1. ;-------------------------------------------------------------------------------
  2. *                                                                              *
  3. * Pro68 - small CLI2ASX user interface                                         *
  4. *                                                                              *
  5. *                                                                              *
  6. *       Filename        pro68.s                                                *
  7. *       Author          Daniel Weber                                           *
  8. *       Version         1.00                                                   *
  9. *       Start           05.07.93                                               *
  10. *                                                                              *
  11. *       Last Revision   12.07.93                                               *
  12. *                                                                              *
  13. ;-------------------------------------------------------------------------------
  14.  
  15.     output    'ram:pro68'
  16.  
  17. ;    opt    o+,q+,ow-,qw-
  18.     verbose
  19.     base    progbase
  20.  
  21.     filenote    'Pro68, written 1993 by Daniel Weber'
  22.  
  23. ;-------------------------------------------------------------------------------
  24.  
  25.     incdir    'include:'
  26.     incdir    'routines:'
  27.  
  28.     incequ    'LVO.s'
  29.  
  30.     include    'proasm/asx.i'
  31.  
  32. ;-------------------------------------------------------------------------------
  33.  
  34. version        equr    "1.00"
  35. gea_progname    equr    "Pro68"
  36.  
  37. ;-- startup control  --
  38. cws_CLIONLY    set    1            ;for CLI usage only
  39. cws_EASYLIB    set    1
  40.  
  41.  
  42. ;-- user definitions --
  43. AbsExecBase    equ    4
  44. DOS.LIB        equ    1
  45.  
  46.  
  47. ;-- asx.i --------------
  48.  
  49. _LVOasx_Assemble    equ    -30    ;library vector
  50.  
  51.  
  52. ;-------------------------------------------------------------------------------
  53. progbase:
  54.     jmp    AutoDetach(pc)
  55.     dc.b    0,"$VER: ",gea_progname," ",version," (",__date2,")",0
  56.     even
  57.  
  58. ;----------------------------
  59. clistartup:
  60.     lea    progbase(pc),a5
  61.  
  62.     clr.b    -1(a0,d0.l)            ;last char must be zero
  63.     move.l    a0,argstring(a5)
  64.     move.l    a0,a1
  65.  
  66.     lea    TitleText(pc),a0        ;print title
  67.     bsr    printtext
  68.  
  69.     move.b    (a1),d0                ;small command line parameter
  70.     beq.s    .usage                ;handling
  71.     cmp.b    #"?",d0
  72.     bne.s    1$
  73.     move.b    1(a1),d0
  74.     beq.s    .usage
  75.     cmp.b    #" ",d0    
  76.     bne.s    1$
  77. .usage:    lea    UsageText(pc),a0        ;print 'usage' message
  78.     bsr    printtext
  79.     bra.s    exit
  80.  
  81.  
  82. 1$:    bsr    main
  83.  
  84. exit:    moveq    #0,d0                ;quit
  85.     bra    ReplyWBMsg
  86.  
  87.  
  88.  
  89.  
  90.  
  91. ;-------------------------------------------------------------------------------
  92. *
  93. * main
  94. *
  95. ;-------------------------------------------------------------------------------
  96.  
  97. main:    move.l    4.w,a6
  98.     lea    asxname(pc),a1
  99.     jsr    _LVOOldOpenLibrary(a6)        ;open asx.library
  100.     tst.l    d0
  101.     beq    noasxlibrary            ;no library found...
  102.     move.l    d0,a4                ;store asxbase
  103.  
  104.     move.l    DosBase(pc),a6
  105.     jsr    _LVOOutput(a6)            ;get StdOut
  106.  
  107.     move.l    argstring(pc),a0
  108.     lea    speciallist(pc),a1
  109.     move.l    d0,ax_StdOut(a1)        ;StdOut
  110.     move.l    a4,a6
  111.     jsr    _LVOasx_Assemble(a6)
  112.     move.l    d0,d7                ;store return value
  113.  
  114.     move.l    a1,a4                ;store special list
  115.     move.l    a6,a1
  116.     move.l    4.w,a6
  117.     jsr    _LVOCloseLibrary(a6)        ;close asx.library
  118.  
  119.     tst.l    d7                ;test return value
  120.     beq    assemblyfailed
  121.     rts
  122.  
  123.  
  124.  
  125. ;
  126. ; no asx.library found
  127. ;
  128. noasxlibrary:
  129.     lea    asxtaskname(pc),a1
  130.     move.l    4.w,a6
  131.     jsr    _LVOFindTask(a6)
  132.     lea    nolibText(pc),a0        ;asx.library not enabled
  133.     tst.l    d0
  134.     bne.s    1$
  135.     lea    noASXText(pc),a0        ;no ASX master task found
  136. 1$:    bra    printtext
  137.  
  138.  
  139. ;
  140. ; assembly failed (probably corrupt 'speciallist')
  141. ;
  142. assemblyfailed:
  143.     lea    failedText(pc),a0
  144.     bra    printtext
  145.  
  146.  
  147. ;-------------------------------------------------------------------------------
  148. *
  149. * sub routines
  150. *
  151. ;-------------------------------------------------------------------------------
  152.  
  153. ;------------------------------------------------
  154. *
  155. * printraw    - print raw text
  156. *
  157. * a0: format string
  158. * a1: rawlist
  159. *
  160. printraw:
  161.     move.l    a3,-(a7)
  162.     lea    workbuffer(pc),a3
  163.     bsr.s    DoRawFmt
  164.     move.l    a3,a0
  165.     bsr    printtext
  166.     movem.l    (a7)+,a3
  167.     rts
  168.  
  169.  
  170. ;------------------------------------------------
  171. *
  172. * DoRawFmt    - Format a string
  173. *
  174. * a0: format
  175. * a1: data stream
  176. * a3: dest. buffer
  177. *
  178. DoRawFmt:
  179.     movem.l    d0-a6,-(a7)
  180.     lea    .setin(pc),a2
  181.     move.l    4.w,a6
  182.     jsr    _LVORawDoFmt(a6)
  183.     movem.l    (a7)+,d0-a6
  184.     rts
  185.  
  186. .setin:    move.b    d0,(a3)+
  187.     rts
  188.  
  189.  
  190. ;------------------------------------------------
  191. *
  192. * printext    - print a given text to StdOut
  193. *
  194. * a0: pointer to text to be written
  195. *
  196. printtext:
  197.     movem.l d0-a6,-(a7)        ;a0: textpointer
  198.     move.l  a0,d2
  199. .loop:    tst.b   (a0)+            ;search end of string
  200.     bne.s   .loop
  201.     move.l  a0,d3
  202.     subq.l  #1,d3
  203.     sub.l   d2,d3            ;length
  204.     beq.s   .nothingtowrite
  205.  
  206.     move.l  DosBase(pc),a6
  207.     jsr    _LVOOutput(a6)        ;get StdOut handle
  208.     move.l    d0,d1
  209.     beq.s    .nothingtowrite
  210.     jsr     _LVOWrite(a6)        ;write text to StdOut
  211.  
  212. .nothingtowrite:
  213.     movem.l (a7)+,d0-a6
  214.     rts
  215.  
  216.  
  217.  
  218. ;-------------------------------------------------------------------------------
  219. *
  220. * external routines
  221. *
  222. ;-------------------------------------------------------------------------------
  223.     include    startup4.r
  224.  
  225.  
  226. ;-------------------------------------------------------------------------------
  227. *
  228. * data
  229. *
  230.  
  231. * texts, messages etc.
  232. asxname:    dc.b    "asx.library",0
  233. asxtaskname:    dc.b    "ASX Master",0
  234.  
  235.  
  236. TitleText:    dc.b    $9b,"1m",gea_progname,$9b,"0m - "
  237.         dc.b    "Shell-ASX Interface v",version,$a
  238.         dc.b    "Written 1993 by Daniel Weber",$a,$a,0
  239.  
  240. UsageText:    dc.b    "Usage: ",$9b,"3mPro68 <ProAsm command line>",$9b,"0m"
  241.         dc.b    $a,0
  242.  
  243. failedText:    dc.b    "failed, job aborted.",$a,0
  244. nolibText:    dc.b    "Couldn't open 'asx.library'.",$a,0
  245. noASXText:    dc.b    "No ASX user interface installed.",$a,0
  246.  
  247.         even
  248.  
  249. * CLI
  250. argstring:    dc.l    0        ;stored pointer to argument string
  251.  
  252. * ASX
  253. speciallist:    dc.l    Pro68Magic
  254.         ds.b    ax_SIZEOF-4
  255. * Exec
  256. rawlist:    ds.l    6        ;Data stream for the RawDoFmt routine
  257.  
  258. * workbuffer
  259. workbuffer:    dx.b    200        ;workbuffer
  260.  
  261.  
  262. ;-------------------------------------------------------------------------------
  263.     end
  264.  
  265.